# -*- coding: utf-8 -*-
from models import SiteCfg
from cmsdj.settings import TEMPLATE_DIRS

def current_cfg(request): 
    if not hasattr(request, 'current_cfg'): 
        request.current_cfg = SiteCfg.current_cfg()

    if (not request.current_cfg.template_dir in TEMPLATE_DIRS):
        TEMPLATE_DIRS.append( request.current_cfg.template_dir )
    print TEMPLATE_DIRS
    return {'current_cfg':request.current_cfg }

#    if hasattr(request, 'current_cfg'): 
#        return {'current_cfg':request.current_cfg }
#    else:
#        try:
#            return {'current_cfg':SiteCfg.current_cfg() }
#        except ObjectDoesNotExist:
#            return {'current_cfg':SiteCfg() }
